package core

import (
	"fmt"
	"github.com/APP/global"
	initialize "github.com/APP/internal/app"
	"github.com/APP/internal/service/system_service"
	"github.com/gin-gonic/gin"
	"go.uber.org/zap"
	"time"
)

func RunServer(a gin.HandlerFunc) {

	// 从db加载jwt数据
	if global.APP_DB != nil {
		jwtService := system_service.JwtService{}
		jwtService.LoadAll()
	}

	Router := initialize.Routers(a)
	address := fmt.Sprintf(":%d", global.APP_CONFIG.System.Addr)
	zap.L().Info("服务器启动成功")
	fmt.Printf(`
	欢迎使用 APP 服务
	默认测试接口地址: http://127.0.0.1%s/ping
	API接口地址: http://127.0.0.1%s/api/v1
	--------------------------------------版权声明--------------------------------------`, address, address)
	fmt.Println(``)
	initServer(address, Router, 10*time.Minute, 10*time.Minute)
}
